package blazingbubble.graphics.lobby;

import blazingbubble.lobby.command.LobbyCommandFactory;
import blazingbubble.graphics.IActivable;

import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.*;

import moltencore.network.protocol.Login;

public class StartScreen extends JPanel implements IActivable, ActionListener {
	private JButton loginButton;

	private Container displayArea;

	private LobbyCommandFactory commandFactory;

	public StartScreen(Container displayArea, LobbyCommandFactory commandFactory) {
		this.displayArea = displayArea;
		this.commandFactory = commandFactory;
		loginButton = new JButton("Login");
		loginButton.addActionListener(this);

		add(loginButton);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		commandFactory.getLogin().login(null);
	}

	@Override
	public void activate() {
		displayArea.removeAll();
		displayArea.add(this);
		((JPanel)displayArea).updateUI();
	}
}
